package com.ruoyi.app.controller.product.mapper;

import com.ruoyi.common.core.dao.BaseMapper;
import com.ruoyi.common.entity.DO.product.ProductDO;
import com.ruoyi.common.entity.DO.product.ShopProductAttributeDO;
import com.ruoyi.common.entity.VO.product.CreditProductVO;
import com.ruoyi.common.entity.VO.product.PetrolProductVO;
import com.ruoyi.common.entity.VO.product.RechargeProductVO;
import com.ruoyi.common.entity.VO.shop.ShopProductSearchVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface IProductMapper extends BaseMapper<ProductDO> {
    /**
     * 获取包含会员权益的充值金额列表
     * @param searchVO 包含会员等级的搜索条件
     * @return
     */
    List<RechargeProductVO> searchRechargeBenefitList(ShopProductSearchVO searchVO);

    List<PetrolProductVO> searchPetrolList(ShopProductSearchVO searchVO);

    List<ShopProductAttributeDO> searchAttributeList(ShopProductSearchVO searchVO);

    List<CreditProductVO> searchCreditList(ShopProductSearchVO searchVO);

    List<PetrolProductVO> searchForBenefitList(ShopProductSearchVO searchVO);

    PetrolProductVO getPetrolProductDetail(ShopProductSearchVO shopProductSearchVO);

    RechargeProductVO getRechargeProductDetail(ShopProductSearchVO shopProductSearchVO);

    CreditProductVO getCreditProductDetail(ShopProductSearchVO shopProductSearchVO);

    CreditProductVO getCreditProductAllDetail(ShopProductSearchVO shopProductSearchVO);

    @Update("UPDATE product set stock=stock-1 WHERE id=#{productId}")
    int stockSubtraction (Long productId);

    @Update("UPDATE shop_product set sale=sale+1 WHERE shop_id=#{shopId} and product_id=#{productId}")
    int shopSaleIncrement(@Param("shopId") Long shopId, @Param("productId") Long productId);

    @Update("UPDATE product set sale=sale+1 WHERE id=#{productId}")
    int saleIncrement(Long productId);
}
